package com.briup.day40;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class IODemo7 {
	
	static class MyFIS extends FileInputStream {

		public MyFIS(File file) throws FileNotFoundException {
			super(file);
		}
		
		public MyFIS(String path) throws FileNotFoundException {
			super(path);
		}
		
		@Override
		public int read() throws IOException {
			System.out.println("read0().....");
			return super.read();
		}
		
		@Override
		public int read(byte[] b) throws IOException {
			System.out.println("read1().....");
			return super.read(b);
		}
		
		@Override
		public int read(byte[] b, int off, int len) throws IOException {
			System.out.println("read2()....." + off + "," + len);
			return super.read(b, off, len);
		}
		
	}
	
	
	public static void main(String[] args) throws Exception {
		
		String path = "src/com/briup/day40/demo7.txt";
		// FileInputStream fis = new FileInputStream(path);
		FileInputStream fis = new MyFIS(path);
		InputStreamReader isr = new InputStreamReader(fis);
		
		int i = -1;
		while((i = isr.read()) != -1) {
			System.out.print((char)i);
		}
		/*char[] buf = new char[10];
		int len = -1;
		while((len = isr.read(buf)) != -1) {
			System.out.print(new String(buf, 0, len));
		}*/
	}
}
